<?php

$npc_typesFields = array(
	"id",
	"name",
	"lastname",
	"level",
	"race",
	"class",
	"bodytype",
	"hp",
	"gender",
	"texture",
	"helmtexture",
	"size",
	"hp_regen_rate",
	"mana_regen_rate",
	"loottable_id",
	"merchant_id",
	"npc_spells_id",
	"npc_faction_id",
	"mindmg",
	"maxdmg",
	"npcspecialattks",
	"aggroradius",
	"face",
	"luclin_hairstyle",
	"luclin_haircolor",
	"luclin_eyecolor",
	"luclin_eyecolor2",
	"luclin_beardcolor",
	"luclin_beard",
	"d_meele_texture1",
	"d_meele_texture2",
	"runspeed",
	"MR",
	"CR",
	"DR",
	"FR",
	"PR",
	"see_invis",
	"see_invis_undead",
	"qglobal",
	"AC",
	"npc_aggro",
	"spawn_limit",
	"attack_speed",
	"findable",
	"STR",
	"STA",
	"DEX",
	"AGI",
	"_INT",
	"WIS",
	"CHA",
	"see_hide",
	"see_improved_hide",
	"trackable"
);

function CreateTableSchema($tablename,$dbname="") {
	global $db;
	global $db_name;
	if ($dbname == "") {$dbname = $db_name;};
	mysql_select_db("information_schema");
	$Schema_query[$tablename] = "SELECT COLUMN_NAME,ORDINAL_POSITION,COLUMN_DEFAULT FROM COLUMNS WHERE TABLE_SCHEMA='" . $dbname . "' AND TABLE_NAME='" . $tablename . "' ORDER BY ORDINAL_POSITION ASC";
	$Schema_result[$tablename] = mysql_query($Schema_query[$tablename],$db);
	if ($Schema_row[$tablename] = mysql_fetch_array($Schema_result[$tablename])) {
		$x = 0;
		global $Schema;
		do {
			$Schema[$tablename][$x++] = $Schema_row[$tablename];
			$Schema[$tablename][$Schema_row[$tablename]["COLUMN_NAME"]] = $Schema_row[$tablename];
		} while ($Schema_row[$tablename] = mysql_fetch_array($Schema_result[$tablename]));
	};
	mysql_select_db($db_name);
};

// CreateTableSchema(items);
// CreateTableSchema(npc_types);

?>